import os
import models
from google.appengine.ext import db
from google.appengine.api import users

template_folder = 'templates'
debug = True

def template_path(template):
    return os.path.join(os.path.dirname(__file__), template_folder, template+'.html')
    
def base_template_data(request):
    user = users.get_current_user()
    local_user = None
    if user: 
        url_text = 'logout'
        url = users.create_logout_url(request.uri)
        local_user = models.User.get_current_user()
    else:
        url_text = 'login'
        url = users.create_login_url(request.uri)
    template_values = {'user_url': url, 'user_url_text': url_text, 'user':user, 'local_user': local_user}
    return template_values
